import React, { useEffect } from 'react'
import axios from 'axios'
import { useRequest, useNetwork } from 'ahooks'
function useMyTitle (title) {
  useEffect(() => {
    document.title = title
  }, [])
}
function getProList () {
  // 需要返回promise的结果
  return axios.get('http://121.89.205.189/api/pro/list')
}
function App() {
  const {data, error, loading} = useRequest(getProList)
  const networkState = useNetwork()
  useMyTitle('哈哈1111')
  console.log('data', data)
  console.log('error', error)
  console.log('loading', loading)
  if (error) {
    return <div>failed to load</div>;
  }
  if (loading) {
    return <div>loading...</div>;
  }
  return <div>
    <h1>{ JSON.stringify(networkState) } </h1>
    {
      data.data.data.map(item => {
      return <div key = { item.proid }> { item.proname }</div>
      })
    }
  </div>;
}

export default App
